﻿using Mysoft.Map.Extensions.Json;
using Mysoft.QuickCode.ServiceProvider;
using Mysoft.Test.Business;
using Mysoft.Test.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Services;

namespace CSWeb.Services
{
    /// <summary>
    /// MysoftService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class MysoftService : System.Web.Services.WebService
    {
        private static BaseService _svr = new BaseService(new WebServiceTest());
        
        /// <summary>
        /// 调用方法并传入参数获取请求结果
        /// </summary>
        /// <param name="methodName">方法名称</param>
        /// <param name="methodParams">方法参数</param>
        /// <returns>请求数据结果</returns>
        [WebMethod]
        public string GetData(string methodName, string methodParams)
        {
            try
            {
                return _svr.Functions[methodName](new ServiceRequest()
                {
                    Data = methodParams //请求参数
                }).Data.ToString(); //返回响应
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
